package com.gnerv.pabu.basic.core.dto;

import com.gnerv.pabu.basic.core.entity.Article;
import com.gnerv.pabu.basic.core.entity.ArticleDetails;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;

/**
 * <p>
 * CMS-文章表
 * </p>
 *
 * @author Gnerv LiGen
 * @since 2019-10-10
 */
@Data
@ToString
@NoArgsConstructor
public class ArticleSaveDTO {

    private static final long serialVersionUID = 1L;

    private String ukId;
    private String title;
    private String author;
    private LocalDateTime gmtRelease;
    private Integer status;
    private Integer sort;

    private String content;

    private String catalogId;

    public Article convert(){
        Article article = new Article();
        BeanUtils.copyProperties(this, article);
        return article;
    }

    public ArticleDetails convertArticleDetails(){
        ArticleDetails articleDetails = new ArticleDetails();
        articleDetails.setArticleId(this.ukId);
        articleDetails.setContent(this.content);
        return articleDetails;
    }


}
